package com.flyme.module.base.client.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.flyme.core.base.supper.entity.EntityMap;
import lombok.Getter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 职位枚举
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@Getter
public enum PostEnum implements IEnum {
    generalManager ("P_01", "总经理"),
    deputyManager ("P_02", "副总经理"),
    regionalDirector("P_03", "大区总监"),
    specialtyDirector("P_04", "专业总监"),
    projectManager("P_05", "项目经理"),
    specialtyManager("P_06", "专业经理"),
    steward("P_07", "管家"),
    clerk("P_08", "专业文员"),
    baseStaff("P_09", "基层员工");
    public String text;
    @EnumValue
    public String code;

    private PostEnum(String code, String text) {
        this.code = code;
        this.text = text;
    }

    private PostEnum(String code) {
        this.text = getText(code);
        this.code = code;
    }

    public static String getText(String code) {
        String v = "";
        for (PostEnum accountTypeEnum : values()) {
            if (accountTypeEnum.code.equals(code)) {
                v = accountTypeEnum.text;
                break;
            }
        }
        return v;
    }

    public static Map<String, Object> getMap() {
        Map<String, Object> map = new HashMap<>();
        for (PostEnum professionEnum : values()) {
            map.put(professionEnum.code, professionEnum.text);
        }
        return map;
    }


    public static List<EntityMap> getList() {
        List<EntityMap> list = new ArrayList<>();
        for (PostEnum professionEnum : values()) {
            EntityMap map = new EntityMap();
            map.put("code", professionEnum.code);
            map.put("name", professionEnum.text);
            list.add(map);
        }
        return list;
    }

    public static void main(String[] args) {
        System.out.println(PostEnum.specialtyManager.code);
    }

    @Override
    public Serializable getValue() {
        return this.code;
    }
}
